package main

import (
	"github.com/karlseguin/ccache/v3"
	"sync"
)

func HandleMessage() {
	InitService()
}

type Service struct {
	cache *ccache.Cache[string]
}

var once sync.Once
var srv *Service

func InitService() *Service {
	once.Do(func() {
		srv = &Service{}
		srv.cache = ccache.New(ccache.Configure[string]()) // New函数起了个协程
	})
	return srv
}

func InitServiceWrong() *Service {
	srv := &Service{}
	srv.cache = ccache.New(ccache.Configure[string]())
	return srv
}
